Micron Document
Fox's Git Mirrors


Displaying Raw • Download

src/Cryptography/Hashes.cpp 9e0fb0258103d1bab3e0e4cf812db1506928bbb6 (9e0fb025) Text, 904 B

#include "Hashes.h"

#include "../Bytes.h"

#include <SHA256.h>
#include <SHA512.h>

using namespace RNS;

/*
The SHA primitives are abstracted here to allow platform-
aware hardware acceleration in the future. Currently only
uses Python's internal SHA-256 implementation. All SHA-256
calls in RNS end up here.
*/

const Bytes RNS::Cryptography::sha256(const Bytes& data) {
//extreme("Cryptography::sha256: data: " + data.toHex() );
SHA256 digest;
digest.reset();
digest.update(data.data(), data.size());
Bytes hash;
digest.finalize(hash.writable(32), 32);
//extreme("Cryptography::sha256: hash: " + hash.toHex() );
return hash;
}

const Bytes RNS::Cryptography::sha512(const Bytes& data) {
SHA512 digest;
digest.reset();
digest.update(data.data(), data.size());
Bytes hash;
digest.finalize(hash.writable(64), 64);
//extreme("Cryptography::sha512: hash: " + hash.toHex() );
return hash;
}

Served by rngit 1.5.0 - Generated in 0.03s